package com.kailong.servlet.student;

import com.kailong.dao.ManageAdviceDao;
import com.kailong.dao.admin.ManageSeatDao;
import com.kailong.pojo.Advice;
import com.kailong.pojo.Seat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/student/adviceSelectAllOfStudent")
public class AdviceSelectAll extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int cpage = 1;
        int count = 10;
        HttpSession session = req.getSession();
        String sno = (String)session.getAttribute("sno");
        String cp = req.getParameter("cp");
        if(cp!=null){
            cpage = Integer.parseInt(cp);
        }
        int arr[]  = ManageAdviceDao.StudentTotalPage(count,sno);
        ArrayList<Advice> list = ManageAdviceDao.studentSelectAll(cpage,count,sno);
        req.setAttribute("advicelist",list);
        req.setAttribute("tsum",arr[0]);
        req.setAttribute("tpage",arr[1]);
        req.getRequestDispatcher("studentAdviceSelect.jsp").forward(req,resp);
    }
}
